package com.fenghongzhang.kotlin5

import android.content.Context
import android.content.SharedPreferences
import android.widget.Toast
import java.lang.StringBuilder

/**
 * 扩展
 */
fun String.toast(context: Context){
    Toast.makeText(context,this,Toast.LENGTH_SHORT).show()
}

fun Number.toast(context: Context){
    Toast.makeText(context,"$this",Toast.LENGTH_SHORT).show()
}

//fun StringBuilder.aaaa(block:StringBuilder.() -> Unit) : StringBuilder{
//    block()
//    return this
//}

fun <T> T.aaaa(block:T.()->Unit):T{
    block()
    return this
}

fun SharedPreferences.open(block:SharedPreferences.Editor.()->Unit){
    val edit = edit()
    edit.block()
    edit.apply()
}

